package cn.zzmx.controller;


import cn.zzmx.entity.ResultMsg;
import cn.zzmx.entity.Role;
import cn.zzmx.entity.UserRole;
import cn.zzmx.service.IRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("role")
public class RoleController {


    @Autowired
    private IRoleService iRoleService;

    @GetMapping("/queryUserNotRole")
    public ResultMsg<Role> queryUserNotRole(String userId){
        List<Role> roles = iRoleService.queryUserNotRole(userId);

        ResultMsg<Role> msg = new ResultMsg<>();
        msg.setCode(0);
        msg.setMsg("查询成功");
        msg.setData(roles);

        return msg;
    }


    @PostMapping("/addUserRole")
    public ResultMsg<Role> addUserRole(@RequestBody UserRole userRole){

        iRoleService.addUserRole(userRole);
        ResultMsg<Role> msg = new ResultMsg<>();
        msg.setMsg("添加成功");

        return msg;
    }

}
